package com.aubrey.threadDemo.lock;

/**
 * 自定义不可重入锁
 * @author Administrator
 *
 */
public class MyLock {
	private boolean isLocked = false;
	
	public  synchronized  void lock() {
		while(isLocked) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		isLocked = true;
	}
	
	public synchronized void unLock() {
		isLocked = false;
		notifyAll();
	}

}
